<?php

defined("IN_CA") or die();

$available_functions = array("add", "edit");

if(!isset($_GET['do']) || !in_array($_GET['do'], $available_functions))
{
	$this->template = new TemplateHandler("adm_content.php", ADM_TEMPLATE_DIR);
	
	$q = $this->db->query(
		"SELECT
			c.id as c_id,
			c.title as c_title,
			m.priority as m_priority,
			m.url as m_url,
			m.title as m_title,
			m.active as m_active,
			m.id as m_id
		FROM
			menu m
		LEFT JOIN
			content c
			ON
				c.id = m.local_cid
		ORDER BY
			m.priority ASC
		"
	);
	
	$data = array();
	
	while($row = $this->db->fetchArray($q))
	{
		$data[] = $row;
	}
	
	$this->template->assign('data', $data);
}
elseif($_GET['do'] == "add")
{
	$this->template = new TemplateHandler("adm_content_editor.php", ADM_TEMPLATE_DIR);
}
elseif($_GET['do'] == "edit")
{
	$this->template = new TemplateHandler("adm_content_editor.php", ADM_TEMPLATE_DIR);
}

?>